<span class="titulo">Base Instalada x Base Ativa</span>
<?php
$link = sybase_connect('getbo', 'carga', 'carga2006') or die("Could not connect !");
$db = sybase_select_db('getbo', $link);
$sql = "select distinct
	d.ano_mes,
	max(case when ds_indicador = 'BASE INSTALADA' then vl_indicador else null end) as base_instalada,
	max(case when ds_indicador = 'BASE ATIVA' then vl_indicador else null end) as base_ativa,
	(max(case when ds_indicador = 'BASE ATIVA' then vl_indicador else null end) / max(case when ds_indicador = 'BASE INSTALADA' then vl_indicador else null end)*100) as percentual

from dba.indicadores_estrategicos ie, dba.d_data d
where ie.dt_referencia = d.data
group by d.ano_mes
order by d.ano_mes";
$rs = sybase_query($sql, $link);
//print_r(sybase_fetch_assoc($rs));

$FC2 = new FusionCharts("MSColumn3DLineDY", "1200", "300");
		
$FC2->setSwfPath("FusionChartsFree/Charts/");
		 
$strParam2="xAxisName=Meses;pYAxisName=Base Instalada;sYAxisName=Base Ativa;decimalPrecision=1;";
$FC2->addColors("4682B4;FF6347;32CD32");
$FC2->setChartParams($strParam2);

while ($linha = sybase_fetch_assoc($rs)) {
	$FC2->addCategory($linha["ano_mes"]);
}	

$rs = sybase_query($sql, $link);
$FC2->addDataset("Base Instalada","showValues=1","decimalPrecision=5");
while ($linha = sybase_fetch_assoc($rs)) {
	$FC2->addChartData($linha["base_instalada"]);	
}

$rs = sybase_query($sql, $link);
$FC2->addDataset("Base Ativa","showValues=1");
while ($linha = sybase_fetch_assoc($rs)) {
	$FC2->addChartData($linha["base_ativa"]);
}

$rs = sybase_query($sql, $link);
$FC2->addDataset("% Atividade","parentYAxis=S");
while ($linha = sybase_fetch_assoc($rs)) {
	$FC2->addChartData($linha["percentual"]);
}

$FC2->renderChart();

sybase_close($link);